let mask=document.querySelector(".mask");
let cha=document.querySelector(".cha");
let make=document.querySelector(".make");
let con=document.querySelector(".con");
let appointment=document.querySelector(".appointment");
let phone=document.querySelector(".phone");
var wenben=document.querySelector(".wenben");
make.onclick=((e)=>{
  var e=e||window.event;
  e.returnValue=false;
  mask.style.display="block";
  setStyle();
})
window.onresize=setStyle;
cha.onclick=()=>{
  mask.style.display="none";
}
function setStyle(){
  appointment.style.left=(innerWidth-appointment.offsetWidth)/2+"px";
  appointment.style.top=(innerHeight-appointment.offsetHeight)/2+"px";
}

//验证手机号码
jQuery.validator.addMethod(
  "telTest",
  function (value) {
    let reg = /^1[3-9]\d{9}$/;
    return reg.test(value);
  },
  "手机号码不正确"
)
$("#form").validate({
  rules: {
    company: {
      required: true,
    },
    lianxi: {
      required: true,
    },
    phone: {
      required: true,
      telTest: true,
    },
    eat:{
      required: true,
    }
  },

  messages: {
    company: {
      required: "公司名称是必填的",
    },
    lianxi: {
      required: "联系人姓名是必填的",
    },
    phone: {
      required: "手机号码是必填的",
    },
    eat: {
      required: "试吃人数是必填的",
    },
  },
  submitHandler: function (form) {
     alert("提交成功");
}
})

// 回到顶部
var dingbu = document.querySelector(".dingbu");
window.onscroll = function () {
  var height=window.innerHeight+scrollY;
  if(height>window.innerHeight){
    dingbu.style.display = "block";
    dingbu.onclick = function () {
      scrollTo({ top: 0, behavior: "smooth" });
    };
  }
    else{
      dingbu.style.display = "none";
    }
  };
  

